<!--首页iframe通讯桥接页面-->
<script type="text/javascript">
    (function () {
        var getUrlPara = function (name, url) {
            url = url || window.location.href;
            var search = getUrlObj(url).search;
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = search.match(reg);
            if (r != null) {
                return decodeURIComponent(r[2]);
            }
            return "";
        };

        var getUrlObj = function (url) {
            url = url || location.href;

            if (url.indexOf('http') === 0) {
                //nothing
            } else if (url.indexOf('//') === 0) {
                url = location.protocol + url;
            } else if (url.indexOf('/') === 0) {
                url = location.protocol + '//' + location.host + url;
            } else if (url.indexOf('/') !== 0) {
                //相对路径
                url = location.protocol + '//' + location.host + location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/' + url;
            }

            var l = document.createElement("a");
            l.href = url;

            var pathname = l.pathname;
            if (pathname.indexOf('/') !== 0) {
                pathname = '/' + pathname;
            }

            return {
                protocol: l.protocol,
                host: l.host,
                hostname: l.hostname,
                search: l.search.replace('?', ''),
                hash: l.hash.replace('#', ''),
                pathname: pathname,
                port: l.port
            };
        };

        setInterval(function () {
            try {
                var hash = location.hash.replace(/^#/, '');

                var height = getUrlPara('height', hash);
                var size = {
                    height: height
                };

                window.top.updateIframeSize(size);
            } catch (e) {
                //nothing
            }
        }, 50);
    })();
</script>